/*
 * Sum.java
 *
 * This program demonstrates the use of for loop to compute the sum of
 * first 10 even numbers.
 *
 */

package com.javacore.day3.article;

/**
 *
 * @author 
 */

public class Sum {
    
    /** Creates a new instance of Sum */
    public Sum() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int i, sum = 0, evenCount = 1;
        
        // Iterate until the sum of first 10 even numbers is computed
        for(i = 0;evenCount <= 10;i++) {
            
            // Check if the value contained by variable i is an even value
            if(i % 2 == 0) {
                evenCount++;
                sum += i;
            }
        }
        System.out.println("Sum of first 10 even numbers is: " + sum);
    }
}
